package com.ssm.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ssm.sfzy.entity.CourseReply;
import com.ssm.sfzy.mapper.CourseReplyMapper;
import com.ssm.sfzy.service.CourseReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author jitwxs
 * @date 2024年04月01日 14:56
 */
@Service
public class CourseReplyServiceImpl implements CourseReplyService {

    @Autowired
    private CourseReplyMapper courseReplyMapper;
    @Override
    public void add(CourseReply entity) {
        courseReplyMapper.insert(entity);
    }

    @Override
    public void edit(CourseReply entity) {
        courseReplyMapper.update(entity);
    }

    @Override
    public void remove(Integer id) {
        courseReplyMapper.delete(id);
    }

    @Override
    public void removeBatch(Integer[] ids) {
        courseReplyMapper.deleteBatch(ids);
    }

    @Override
    public List<CourseReply> find(CourseReply entity) {
        return courseReplyMapper.select(entity);
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, CourseReply entity) {
        PageHelper.startPage(pageNum,pageSize);
        List<CourseReply> list = courseReplyMapper.select(entity);
        PageInfo<CourseReply> pageInfo = new PageInfo<>(list);

        Map<String,Object> map = new HashMap<>();
        map.put("list",pageInfo.getList());
        map.put("total",pageInfo.getTotal());
        return map;
    }

    @Override
    public CourseReply findById(Integer id) {
        return courseReplyMapper.selectById(id);
    }
}
